import request from "@/utils/request";

/**
 * 客户列表
 * @param { CustomList } params
 * @returns { CustomListRes }
 */
export const getCrmList = params => {
  return request({
    url: "/crm/info/list",
    method: "get",
    params
  });
};

/**
 * 查重
 * @param { string } mobileCode
 */
export const customCheckCrm = mobileCode => {
  return request({
    url: `/crm/info/getPlagiarismCheck/${mobileCode}`,
    method: "get"
  });
};

/**
 * 新建客户
 * @param { CustomAdd } data
 */
export const addClientInfo = data => {
  return request({
    url: "/crm/info/add",
    method: "post",
    data
  });
};

/**
 * 新增获取当前用户默认的部门ID和用户ID
 */
export const defaultDepartmentAndUser = () => {
  return request({
    url: "/crm/info/getAddCrmCustomerInfo",
    method: "get"
  });
};

/**
 * 客户基本信息修改
 * @param { CustomUpdate } data
 */
export const editClientInfo = data => {
  return request({
    url: "/crm/info/update",
    method: "put",
    data
  });
};

/**
 * 客户信息详情
 * @param { string } customerId
 * @returns { object }
 */
export const getClientInfo = customerId => {
  return request({
    url: `/crm/info/getInfo/${customerId}`,
    method: "get"
  });
};

/**
 * 客户基本信息 + 跟进记录
 * @param { string } customerId
 */
export const clientInfoAndFollow = customerId => {
  return request({
    url: `/crm/info/getInfoPenetration/${customerId}`,
    method: "get"
  });
};

/**
 * 删除
 * @param { string } customerId
 */
export const deleteClientInfo = customerId => {
  return request({
    url: `/crm/info/deleteInfo/${customerId}`,
    method: "delete"
  });
};

/**
 * 新增客户跟进
 * @param { CustomTrackAdd } data
 */
export const addTrack = data => {
  return request({
    url: "/crm/track/add",
    method: "post",
    data
  });
};

/**
 * 客户流失申请
 * @param { string } customerId
 * @param  { ApplyLossParmas } data
 */
export const applyLoss = (data, customerId) => {
  return request({
    url: `crm/info/lost/apply/${customerId}`,
    method: "post",
    data
  });
};

/**
 * 服务团队
 * @param { string } customerId
 * @returns { Array<ServiceTeamData> }
 */
export const getServiceTeam = customerId => {
  return request({
    url: `/crm/info/getServiceTeam/${customerId}`,
    method: "get"
  });
};

/**
 * 客户阶段列表
 * @param { string } customerId -客户ID
 * @returns { Array<ClientStageData> }
 */
export const getStageList = customerId => {
  return request({
    url: `/crm/info/stage/list/${customerId}`,
    method: "get"
  });
};

/**
 * 客户阶段内容视图
 * @param { string } customerId -客户ID
 */
export const getStageView = customerId => {
  return request({
    url: `/crm/info/stage/content/${customerId}`,
    method: "get"
  });
};

/**
 * 客户阶段——办理CRM流程任务
 * @param { string } stageTaskId -客户阶段任务ID
 * @param { TaskHandleParams } data
 */
export const subStageViewContent = (stageTaskId, data) => {
  return request({
    url: `/crm/info/transact/${stageTaskId}`,
    method: "post",
    data
  });
};
